<%@include file="../common.jsp"%>

<script type="text/javascript">
	
	$(document).ready(
		function(){
			$("#saveLocationMasterDetails").attr("action",'<c:url value="/saveLocationMasterDetails.htm"></c:url>');
			loadBelowValues('state','district');
// 			$("#city").focus();
			/* if($("#district").val() == -1){
				alert("hi");
			} */
			$("input.disableInputField").attr("disabled","disabled");
			var stateSetSize = "<c:out value='${fn:length(stateSet)}' />";
			
			if(stateSetSize == 0){
				$("input.disableInputField").removeAttr("disabled");
			}
			
		});
	
</script>

<div>
	<form:form commandName="locationMasterForm" id="saveLocationMasterDetails">
		<table  class="adminFilterTable">
			<tr class="tableChildHeaderColor">
				<td colspan="7" align="center">LOCATION MASTER</td>
				<td class="spacingColumnWidthLess"></td>
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
			<tr> 
				<td align="left" colspan="4" style="font-family: verdana; font-size: 12px;"> All fields are mandatory.</td> 
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
			<tr>
				<td class="spacingColumnWidthLess"></td>
				<td class="formLabel">State</td>
				<td class="spacingColumnWidthLess"></td>
				<td class="formField"><form:select path="state" id="state" onchange="loadBelowValues(this.id,'district');">
							
						<c:forEach var="stateSet" items="${stateSet}">
							<form:option value="${stateSet}">${stateSet}</form:option>
						</c:forEach>
							<form:option value="-1">Others</form:option>
					</form:select>
				</td>
				<td class="spacingColumnWidthLess"></td>
				<td>
					<form:input path="newState" id="newState" cssClass="disableInputField"/>
					<form:errors cssClass="errorMessage" path="state"></form:errors>
				</td>
				<td class="spacingColumnWidthLess"></td>
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
			<tr>
				<td class="spacingColumnWidthLess"></td>
				<td class="formLabel">District</td>
				<td class="spacingColumnWidthLess"></td>
				<td class="formField">
						<form:select path="district" id="district" onchange="loadBelowValues(this.id,'city');"></form:select>
				</td>
				<td class="spacingColumnWidthLess"></td>
				<td>
					<form:input path="newDistrict" id="newDistrict" cssClass="disableInputField"/>
					<form:errors cssClass="errorMessage" path="district"></form:errors>
				</td>
				<td class="spacingColumnWidthLess"></td>
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
			<tr>
				<td class="spacingColumnWidthLess"></td>
				<td class="formLabel">City</td>
				<td class="spacingColumnWidthLess"></td>
				<td class="formField">
					<form:select path="city" id="city" onchange="enableDisableCityFields(this.id);"></form:select>
				</td>
				<td class="spacingColumnWidthLess"></td>
				<td>
					<form:input path="newCity" id="newCity" cssClass="disableInputField"/>
					<form:errors cssClass="errorMessage" path="city"></form:errors>
				</td>
				<td class="spacingColumnWidthLess"></td>
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
			<tr class="odd">
				<td class="spacingColumnWidthLess"></td>
				<td></td>
				<td class="spacingColumnWidthLess"></td>
				<td colspan="4"> <input class="formButton ui-corner-all" type="button" value="Add New Location" onclick="javascript:addEntity('saveLocationMasterDetails')"> </td>
				
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
		</table>
	</form:form>
</div>
<br/>
<c:if test="${errorCount eq 0}">
	<c:choose>
		<c:when test="${resultOfEntry}">
			Operation Done Successfully
		</c:when>
		<c:otherwise>
			<span class="errorMessage"> City already exists on selected district and state. </span>
		</c:otherwise>
	</c:choose>
</c:if>

<br/>
<br/>

<div>
	<form:form commandName="uploadLocationForm" id="uploadLocationForm" enctype="multipart/form-data" method="POST" action="uploadLocationExcel.htm">
		<table  class="adminFilterTable" style="width: 50%;">
			<tr class="tableChildHeaderColor">
				<td colspan="7" align="center">LOCATION MASTER (Upload Using Excel)</td>
				<td class="spacingColumnWidthLess"></td>
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
			<tr> 
				<td align="left" colspan="4" style="font-family: verdana; font-size: 12px;"> All fields are mandatory.</td> 
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
			<tr>
				<td class="spacingColumnWidthLess"></td>
				<td class="formLabel">Path to Excel :</td>
				<td class="spacingColumnWidthLess"></td>
				<td class="formField">
					<form:input type="file" name="inputFile" path="inputFile" />
				</td>
				<td class="spacingColumnWidthLess"></td>
			</tr>
			
			<tr>
				<td class="spacingColumnWidthLess"></td>
				<td></td>
				<td class="spacingColumnWidthLess"></td>
				<td colspan="4"> <input class="formButton ui-corner-all" type="submit" value="UPLOAD"> </td>
				
			</tr>
			<tr class="formSpacingRow"><td></td> </tr>
		</table>
	</form:form>
</div>
